//
//  HistoryViewController.m
//  XMLY
//
//  Created by lanou on 15/11/7.
//  Copyright © 2015年 曾杰. All rights reserved.
//

#import "HistoryViewController.h"
#import "MusicViewCell.h"
#import "MusicTableViewController.h"
#import "HistoryRecommendedViewController.h"
#import "HACursor.h"
#import "UIView+Extension.h"
@interface HistoryViewController ()
@property (nonatomic, strong) NSArray *items;
@property (nonatomic, strong)MusicTableViewController * musicVC;
@property (nonatomic, strong)HistoryRecommendedViewController * remmendVC;
@property (nonatomic, strong)UINavigationController * navc;
@property (nonatomic, strong)UINavigationController * navc1;
@property (nonatomic, strong)HACursor *cursor;
@property (nonatomic, strong)NSMutableArray * pageViews;
@end

@implementation HistoryViewController

- (NSArray *)items {
    if (_items == nil) {
        _items = @[@"推荐", @"军事", @"野史奇闻", @"名家讲坛", @"名人档案", @"国学新说", @"地方人文", @"佛学心灵", @"文青", @"诗歌爱好"];
    }
    return _items;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.titleLabel.text = @"历史";
    
    
    _cursor = [[HACursor alloc]init];
    _cursor.frame = CGRectMake(0, 64, self.view.width, 45);
    _cursor.titles = self.items;
    _cursor.pageViews = [self createPageViews];
    //设置根滚动视图的高度
    _cursor.rootScrollViewHeight = self.view.frame.size.height -109;
    //默认值是白色
    _cursor.titleNormalColor = [UIColor blackColor];
    //默认值是白色
    _cursor.titleSelectedColor = [UIColor redColor];
    //是否显示排序按钮
    _cursor.showSortbutton = NO;
    //默认的最小值是5，小于默认值的话按默认值设置
    _cursor.minFontSize = 15;
    //默认的最大值是25，小于默认值的话按默认值设置，大于默认值按设置的值处理
    _cursor.maxFontSize = 18;
    //cursor.isGraduallyChangFont = NO;
    //在isGraduallyChangFont为NO的时候，isGraduallyChangColor不会有效果
    //cursor.isGraduallyChangColor = NO;
    [self.view addSubview:_cursor];
    
    
    // Do any additional setup after loading the view.
}


-(NSMutableArray *)createPageViews
{
    _pageViews = [NSMutableArray arrayWithCapacity:0];
    _remmendVC = [[HistoryRecommendedViewController alloc]init];
    
    [_pageViews addObject:_remmendVC.view];
    
    
    for (int i = 1 ; i< self.items.count; i++) {
        
        _musicVC = [[MusicTableViewController alloc]init];
        
        switch (i) {
                
            case 1:
            {
                
                //
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%90%8D%E4%BA%BA%E6%A1%A3%E6%A1%88";
                
                
                
            }
                break;
            case 2:
            {
                
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E9%87%8E%E5%8F%B2%E5%A5%87%E9%97%BB";
                
            }break;
            case 3:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%90%8D%E5%AE%B6%E8%AE%B2%E5%9D%9B";
                
                
            }
                break;
            case 4:
            {
                
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%90%8D%E4%BA%BA%E6%A1%A3%E6%A1%88";
                
                
            }
                break;
                
            case 5:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%9B%BD%E5%AD%A6%E6%96%B0%E8%AF%B4";
            }
                break;
            case 6:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E5%9C%B0%E6%96%B9%E4%BA%BA%E6%96%87";
                
            }
                break;
                
            case 7:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E4%BD%9B%E5%AD%A6%E5%BF%83%E7%81%B5";
            }
                break;
            case 8:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E6%96%87%E9%9D%92%E9%9B%86%E4%B8%AD%E8%90%A5";
            }
                break;
                
            case 9:
            {
                _musicVC.urlStr = @"http://mobile.ximalaya.com/mobile/discovery/v1/category/album?calcDimension=hot&categoryId=9&device=android&pageId=1&pageSize=20&status=0&tagName=%E8%AF%97%E6%AD%8C%E7%88%B1%E5%A5%BD%E8%80%85";
            }
                break;
                           
        }
        [_pageViews addObject:_musicVC.view];
        
        
    }
    return _pageViews;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
